<template>
    <teleport to="#back">
        <div class='d-flex justify-content-center align-items-center h-100 w-100 loading-container'
            :style="{ 'background-color': background || '' }">
            <div class="loading-content">
                <div class="spinner-border text-info mb-2" role="status">
                    <span class="visually-hidden">{{ text || 'Loading...' }}</span>
                </div>
                <p v-if="text" class="text-primary small">{{ text }}</p>
            </div>
        </div>
    </teleport>
</template>
<script lang='ts'>
import { defineComponent } from 'vue';
import useDOMCreate from '@/hooks/useDOMCreate'

export default defineComponent({
    props: {
        text: {
            type: String
        },
        background: {
            type: String
        }
    },

    setup(props, context) {
        useDOMCreate('back')
    }

})
</script>
<style lang='scss'>
.loading-container {
    background: rgba(255, 255, 255, .5);
    z-index: 100;
    position: fixed;
    top: 0;
    left: 0;
}

.loading-container {
    text-align: center;
}
</style>
